package com.yanqu.road.server.cmd.chefduel.process2;

import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.pb.chefduel.ChefDuelProto;
import com.yanqu.road.server.cmd.CrossCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.manager.chefduel.CrossChefDuelMgr;
import com.yanqu.road.server.protocol.Protocol;


@Cmd(code = Protocol.C_CROSS_CHEF_DUEL2_RECORD, desc = "小当家第2阶段获取记录")
public class CrossGetRecordCmd extends CrossCommand {

    private long userId;
    private int activityId;
    private long realServerId;

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        ChefDuelProto.CrossChefDuel2GetRecordMsg reqMsg = ChefDuelProto.CrossChefDuel2GetRecordMsg.parseFrom(packet.getBytes());
        userId = packet.getPlayerId();
        activityId = reqMsg.getActivityId();
        if(reqMsg.hasServerId()){
            realServerId = reqMsg.getServerId();
        }
        return true;
    }

    @Override
    public void execute(YanQuMessage packet) throws Exception {
        CrossChefDuelMgr.getRecord(activityId, realServerId > 0 ? realServerId : serverId, userId);
    }

    @Override
    public void sendData() {

    }

}
